<script setup lang="ts">
import type { OrderModel } from '~/model/OrderModel'
import Api from '~/api'
import OrderBriefTable from '~/components/order/OrderBriefTable.vue'
import SaleToday from '~/components/statistics/SaleToday.vue'

const router = useRouter()

const latestOrder = ref([] as OrderModel[])

onMounted(async () => {
  const paged = await Api.Order.getPaged()
  const orders = paged.objects
  const a = 5
  const latestA = orders.filter(x => !x.invalid).slice(0, a)
  latestOrder.value = latestA
})

function goAllOrder() {
  router.push('/orders')
}
</script>

<template>
  <div of-auto pb14>
    <SaleToday />

    <NavList />

    <div mb0 paper of-hidden pa0>
      <OrderBriefTable :orders="latestOrder" />
      <div h-14 flex items-center justify-center bg-light-2 @click="goAllOrder">
        <div text-blue-600>
          查看所有
        </div>
      </div>
    </div>
  </div>
</template>

<route lang="yaml">
meta:
  title: 辽西塑业ERP
</route>
